using System;
using System.Collections.Generic;
using System.Text;
using Com.ContentRendering.Api.RenderEngine.Resolver;
using Com.ContentRendering.Api.RenderEngine.Reader;
using System.IO;

namespace Com.ContentRendering.Api.RenderEngine
{
    /// <summary/>
    public class DocumentRender
    {
        /// <summary/>
        public void Render(
            TextWriter writer,
            InputNodeInterface inputNode,
            InputDataInterface inputData)
        {
            AbstractResolver resolver = new ComponentResolver(
                inputNode,
                inputData);

            // use the reader to get the data out of the resolver
            ResolverReader reader = new ResolverReader(resolver);

            // read each record and copy it to the output
            while (reader.MoveNext())
            {
                writer.Write(reader.Value);
            }

            // purge the buffer
            writer.Flush();
        }
    }
}
